;******************************************************************************
;*	Copyright (C), 1999-2001  SEIKO EPSON Corp.
;*  ALL RIGHTS RESERVED
;*
;*	File: FABS.S
;*
;*	C Standard Library Function double fabs(double x) 
;*	The "fabs" function calculates the absolute value of x.
;*
;*	Revision History
;*	12/08/1999	Created by H.Ishida
;*	2001/12/06	T.Tazaki for GNU33(Linux)
;******************************************************************************
;
; --- Format of floating point (double precision) ---
;
;  63|62         52|51               32|31                                0
;   -----------------------------------------------------------------------
;  | |   exponent  |                    fraction                           |
;   -----------------------------------------------------------------------
;  |    12 bits          20 bits       |             32 bits               |
;  |            lower word             |            higher word            |

;==============================================================================
;	Function: double fabs(double x)
;
;	Input:  %r6: Argument x in double (low).
;               %r7: Argument x in double (high).
;
;	Output: %r4: Return vlaue, absolute value of x in double (low).
;		%r5: Return value, absolute value of x in double (high).
;
	.section .text
	.align 1
	.global fabs
	.type	fabs,@function

fabs:
;
;	Copy the input value in the register r7:r6
;	to  the output value in the register r5:r4.
;
	ld.w	%r4,%r6		; Copy input to output reg (low).
	ld.w	%r5,%r7		; Copy input to output reg (high).
;
;	Clear the sign bit (MSB, 31th bit) by shifting to the left one bit
;	and then shifting back to the right one bit.
;
	sll	%r5,1		; Shift to the left  by one bit.
	srl	%r5,1		; Shift back to the right by one bit.
	ret
;
;	Return value: %r4 = fabs in double (low).
;		      %r5 = fabs in double (high).
;